<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>实训2.输出三角形</title>
    <style>
      * {
        text-align: center;
      }
    </style>
    <script type="text/javascript">
      var inputNum = prompt("请输入一个整数:");

      inputNum <= 5 ? case1() : case2();

      function case1() {
        case2();

        for (var i = inputNum; i > 0; i--) {
          for (var j = i; j <= inputNum; j++) {
            document.write("* &nbsp&nbsp&nbsp");
          }
          document.write("</br>");
        }
      }

      function case2() {
        document.write("你输入的数为:" + inputNum + "</br>");
        for (var i = 0; i < inputNum; i++) {
          for (var j = inputNum; j > i; j--) {
            document.write("* &nbsp&nbsp&nbsp");
          }
          document.write("</br>");
        }
      }
    </script>
  </head>

  <body></body>
</html>
